import java.io.*;
import java.util.*;

public class Test
{

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws Exception
    {
        int test = Integer.parseInt(args[0]);
        
        switch (test)
        {
        /*case 1:
            
            // Test 1 - Create rooms and bookings
            Rooks system = new Rooks();
            Room room1 = new Room();
            Room room2 = new Room();
            
            Time oT = new Time(8,30);
            Time cT = new Time(17,30);
            
            room1.setOpenTime(oT);
            room1.setCloseTime(cT);
            room1.setCapacity(50);
            room1.addItem("laptop", 1);
            room1.addItem("projector", 1);
            
            room2.setCapacity(70);
            room2.setOpenTime(oT);
            room2.setCloseTime(cT);
            room2.addItem("desks", 1);
            room2.addItem("bowl", 1);
            
            system.addRoom(room1,"Th");
            system.addRoom(room2,"Cr");

            Booking booking1 = new Booking();
            Booking booking2 = new Booking();

            booking1.setStartTime(2010, 10, 18, 13, 30);
            booking1.setEndTime(2010, 10, 18, 14, 30);

            booking2.setStartTime(2010, 10, 18, 14, 30);
            booking2.setEndTime(2010, 10, 18, 15, 30);

            room1.addBooking(booking1, "Tim");
            room2.addBooking(booking2, "Kenny");

            system.createFiles();
            
            break;
        
        case 2:
            //Test 2 - Create rooms and files to store database
            Rooks system2 = new Rooks();
            
            system2.createRooms();
            system2.createFiles();
            
            break;
            
        case 3:
            
            //Test 3 - sort room list by capacity
            ArrayList<Room> rooms = new ArrayList<Room>();
            Room room3 = new Room();
            room3.setCapacity(25);
            
            Room room4 = new Room();
            Room room5 = new Room();
            
            room4.setCapacity(50);
            
            room5.setCapacity(70);

            rooms.add(room4);
            rooms.add(room5);
            rooms.add(room3);

            System.out.println("Rooms before sort:-");

            for(Room room : rooms)
            {
                System.out.println(room.getCapacity());
            }

            Collections.sort(rooms);

            System.out.println("\nRooms after sort:-");

            for(Room room : rooms)
            {
                System.out.println(room.getCapacity());
            }
            
            break;
            
        case 4:
            //Test 4 - insert rooms in the correct place

            Rooks system4 = new Rooks();
            
            Room room1T4 = new Room();
            Room room2T4 = new Room();
            Room room3T4 = new Room();
            
            room1T4.setCapacity(45);
            room2T4.setCapacity(60);
            room3T4.setCapacity(10);
            
            system4.addRoom(room1T4, "Lecture1");
            system4.addRoom(room2T4, "Lecture2");
            system4.addRoom(room3T4, "Lecture3");

            System.out.println("\nSorted rooms from insert only:-");

            for(Room room : system4.getOrderedRoomList())
            {
                System.out.println(room.getCapacity());
            }
            
            break;
            
        case 5:
            // Test 5 - test sorting of bookings
            Room timeRoom = new Room();
           
            Booking booking3 = new Booking();
            Booking booking4 = new Booking();
            Booking booking5 = new Booking();
            Booking booking6 = new Booking();

            booking3.setStartTime(2010, 10, 18, 12, 30);
            booking4.setStartTime(2010, 10, 18, 8, 30);
            booking5.setStartTime(2010, 10, 18, 18, 30);
            booking6.setStartTime(2010, 10, 18, 9, 30);
            
            timeRoom.addBooking(booking3,"blah");
            timeRoom.addBooking(booking4,"blar");
            timeRoom.addBooking(booking5,"blur");
            timeRoom.addBooking(booking6,"bling");
            
            System.out.println("\nSorted bookings:-");

            for(Booking booking : timeRoom.getOrderedBookings())
            {
                System.out.println(booking.printStartTime());
            }
            
            break;
            
        case 6:
         // Test 6 - test isBooking
            
            Room Test6Room = new Room();
            
            Booking booking7 = new Booking();
            Booking booking8 = new Booking();

            booking7.setStartTime(2010, 10, 18, 13, 30);
            booking7.setEndTime(2010, 10, 18, 14, 30);

            booking8.setStartTime(2010, 10, 18, 13, 29);
            booking8.setEndTime(2010, 10, 18, 14, 30);
            
            Test6Room.addBooking(booking7,"Blue");
            System.out.println(Test6Room.isClash(booking8.getStartTime(), booking8.getEndTime()));
            
            break;*/
            
        case 7:
            // Test 7 - test Query
            Rooks system7 = new Rooks();
            
            system7.createRooms();
            system7.queries();
            
            system7.createFiles();
            
            break;

        case 8:
            // Test 8, reading in from room file
            Rooks system8 = new Rooks();

            system8.readRoomFile(new File("rooms.txt"));

            for(String roomName : system8.getRoomMap().keySet())
            {
                System.out.println("Room: " + roomName);
            }

            break;

        case 9:
            // Test 9, reading in a booking file
            Rooks system9 = new Rooks();

            system9.readRoomFile(new File("rooms.txt"));
            system9.readBookingFile(new File("bookings.txt"));

            for(Room room : system9.getRoomMap().values())
            {
                for(String bookingName : room.getBookingsMap().keySet())
                {
                    System.out.println("Room: " + room.getName()
                        + "\nBooking: " + bookingName);
                }
            }

            break;

        case 10:
            // Test 10, first text-based release
            Rooks system10 = new Rooks();
            system10.run();

            break;

        default:
            System.err.println("No test number found");
        }
    }
}

